/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxinline.servico;

import br.com.foxinline.modelo.Protesto;
import br.com.foxinline.modelo.SituacaoProtesto;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.Query;

/**
 *
 * @author roniere
 */
@Stateless
public class SituacaoProtestoServico extends ServicoGenerico<SituacaoProtesto> {

    public SituacaoProtestoServico() {
        super(SituacaoProtesto.class);
    }
    
    public List<SituacaoProtesto> situacoesPorProtesto(Protesto protesto){
        String sql = "Select sp from SituacaoProtesto sp JOIN sp.protesto p"
                + " where p.id = :protesto order by sp.id DESC";
        
        Query q = getEntityManager().createQuery(sql);
        q.setParameter("protesto", protesto.getId());
        
        return q.getResultList();
    }
    
}
